/**
 * @param {number[]} arr
 * @param {number} k
 * @return {number[]}
 * @description api
 */

var getLeastNumbers = function (arr, k) {
    arr.sort((a, b) => a - b)
    return arr.splice(0, k)
};

getLeastNumbers([3, 2, 1], 2)